Why is `cmd /C` living after it did its job?
Posted
by
acidzombie24
on Super User
See other posts from Super User
or by acidzombie24
Published on 2012-08-28T19:42:23Z
Indexed on
2012/08/28
21:42 UTC
Read the original article
Hit count: 180
My question is why does "cmd" exist (idle) in my process after i update my exe?
In my code i run this code to update myself and launch
var args = string.Format(@"/C ping 1.1.1.1 -n 1 -w 3000 & move /Y ""{0}"" ""{1}"" & ""{1}"" {2}", updateFn, fn, exeargs);
new Process() { StartInfo = new ProcessStartInfo(@"cmd", args) { CreateNoWindow = true, UseShellExecute = false } }.Start();
Environment.Exit(0);
The idea is i exit right away and have ping stall for 3seconds before trying to replace my current exe with my updated exe. Then i launch with the necessary args
The full arg for cmd looks like this
/C ping 1.1.1.1 -n 1 -w 3000 & move /Y "c:\path\update" "c:\path\my.exe" & "c:\path\my.exe" exeargs
Everything works fine however i see cmd in the taskmanager (looks to be idle) after my process is launched and correctly working. Why?
© Super User or respective owner